Skip to content

feat: added configurable ttl for SAML Resonse creation#949

Merged
deepakprabhakara merged 3 commits intomainfrom
idfed/configurable-ttl
Jan 15, 2026
Merged

feat: added configurable ttl for SAML Resonse creation#949
deepakprabhakara merged 3 commits intomainfrom
idfed/configurable-ttl

Conversation

@deepakprabhakara
Copy link
Collaborator

No description provided.

@pi1814
Copy link
Collaborator

pi1814 commented Jan 15, 2026

lgtm, maybe a test like below can be added:

it('Should create a SAML response with custom ttlInMinutes', async function () {
    const ttlInMinutes = 30;
    const json = {
      audience: 'http://sp.example.com/demo1/metadata.php',
      issuer: 'http://idp.example.com/metadata.php',
      acsUrl: 'http://sp.example.com/demo1/index.php?acs',
      claims: {
        raw: {
          'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier':
            '_ce3d2948b4cf20146dee0a0b3dd6f69b6cf86f62d7',
        },
      },
      requestId: 'ONELOGIN_4fee3b046395c4e751011e97f8900b5273d56685',
      privateKey: oktaPrivateKey,
      publicKey: oktaPublicKey,
      ttlInMinutes,
    };

    const response = await createSAMLResponse(json);

    // Extract NotOnOrAfter and NotBefore from the Conditions element
    const notOnOrAfterMatch = response.match(/NotOnOrAfter="([^"]+)"/);
    const notBeforeMatch = response.match(/NotBefore="([^"]+)"/);

    assert.ok(notOnOrAfterMatch, 'NotOnOrAfter attribute should exist');
    assert.ok(notBeforeMatch, 'NotBefore attribute should exist');

    const notOnOrAfter = new Date(notOnOrAfterMatch[1]);
    const notBefore = new Date(notBeforeMatch[1]);

    // The difference should be exactly ttlInMinutes
    const diffInMinutes = (notOnOrAfter.getTime() - notBefore.getTime()) / (1000 * 60);
    assert.strictEqual(diffInMinutes, ttlInMinutes);
  });

@deepakprabhakara
Copy link
Collaborator Author

@pi1814 Thanks, added test for default and custom ttlInMinutes.

@deepakprabhakara deepakprabhakara merged commit fb3f6d5 into main Jan 15, 2026
2 checks passed
@deepakprabhakara deepakprabhakara deleted the idfed/configurable-ttl branch January 15, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants